Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

408
Views
Axios Delete operation on React-bootstrap-table displaying [object%20Object] on the browser's console

I am trying to perform an axios delete operation on a react-bootstrap-table, but I am getting this error on the console

  DELETE http://localhost:9000/api/terminals/[object%20Object]
  Uncaught (in promise) Error: Request failed with status code 400

These are the codes

const

  const apiUrl = 'api/terminals';

UseState and UseEffect

     const [data, setData] = useState([]);

       useEffect(() => {
       getData();
       }, []);

      const getData = () => {
     axios(apiUrl).then(res => {
     setData(res.data);
    });
    };

Axios delete

        const handleDelete = rowId => {
        axios.delete(`${apiUrl}/${rowId}`).then(() => setData(data));
        };

Modal Content

     const ModalContent = () => {
          return (
             <>
      <Modal show={showModal} onHide={handleClose}>
      <Modal.Header closeButton>
        <Modal.Title>Confirm delete operation</Modal.Title>
      </Modal.Header>
      <Modal.Body>Are you sure you want to delete this Terminal? 
      </Modal.Body>
      <Modal.Footer>
        <Button variant="secondary" onClick={handleClose}>
          Cancel
        </Button>
        <Button onClick={id => handleDelete(id)}>Confirm</Button>
      </Modal.Footer>
    </Modal>
   </>
   );
  };

main jsx with bootstrap Table

  <>
  <BootstrapTable
    keyField="id"
    data={data}
    columns={columns}
    striped
    hover
    condensed
    pagination={paginationFactory()}
    cellEdit={cellEdit}
    filter={filterFactory()}
    noDataIndication="Table is Empty"
   
    />
    {showModal ? <ModalContent /> : null}
  </>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You use an object instead of a string in the delete url. Normally you get an event from a onClick and not the id. If you get the id from somewhere else in the code that you do not show the you could try this.

<Button variant="primary" onClick={() => handleDelete(id)}>
   Confirm
</Button>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!